package migrations

import (
	"github.com/goravel/framework/contracts/database/schema"
	"github.com/goravel/framework/facades"
)

type M20250703094531CreateFileTable struct {
}

// Signature The unique signature for the migration.
func (r *M20250703094531CreateFileTable) Signature() string {
	return "20250703094531_create_file_table"
}

// Up Run the migrations.
func (r *M20250703094531CreateFileTable) Up() error {
	if !facades.Schema().HasTable("file") {
		return facades.Schema().Create("file", func(table schema.Blueprint) {
			table.ID()
			table.Integer("category_id").Default(0).Comment("分类ID")
			table.String("origin_name").Comment("原始文件名")
			table.String("file_type").Comment("文件类型")
			table.String("file_md5").Comment("文件md5值")
			table.String("storage_driver").Comment("存储驱动")
			table.String("storage_name").Comment("存储文件名")
			table.String("tags", 300).Comment("标签")
			table.SmallInteger("status").Comment("审核状态")
			table.Integer("creator_id").Default(0).Comment("创建人ID")
			table.String("creator_name").Default("").Comment("创建人名称")
			table.TimestampsTz()

			table.Index("origin_name")
			table.Index("tags")
		})
	}

	return nil
}

// Down Reverse the migrations.
func (r *M20250703094531CreateFileTable) Down() error {
	return facades.Schema().DropIfExists("file")
}
